<?php
	class loainguoidungdb
	{
		public function Add($TenLoaiNguoiDung, $MoTa )
		{
			$sql="INSERT INTO `tbl_loainguoidung`(`TenLoaiNguoiDung`, `MoTa`) VALUES ('$TenLoaiNguoiDung', '$MoTa')";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Delete($MaLoaiNguoiDung)
		{
			$sql = "DELETE FROM `tbl_loainguoidung` WHERE MaLoaiNguoiDung = $MaLoaiNguoiDung";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function Update($MaLoaiNguoiDung, $TenLoaiNguoiDung, $MoTa)
		{
			$sql = "UPDATE `tbl_loainguoidung` 
					SET `TenLoaiNguoiDung`='$TenLoaiNguoiDung', 
						`MoTa`='$MoTa',
					WHERE `MaLoaiNguoiDung`=$MaLoaiNguoiDung";
			$data = new dataservice();
			return $data->ExecuteNonQuery($sql);
		}
		
		public function GetList($MaLoaiNguoiDung, $TenLoaiNguoiDung, $MoTa)
		{
			$sql = "SELECT * FROM `tbl_loainguoidung` WHERE 1";
			if($MaLoaiNguoiDung != 0)
				$sql .= " AND MaLoaiNguoiDung = $MaLoaiNguoiDung";
			
			if($TenLoaiNguoiDung != "")
				$sql .= " AND TenLoaiNguoiDung LIKE '%$TenLoaiNguoiDung%'";
			
			if($MoTa != "")
				$sql .= " AND MoTa LIKE '%$MoTa%'";
				
			$data = new dataservice();
			return $data->ExecuteQuery($sql);
		}
		
	}
?>